﻿using System;
namespace MigratorCore.Status
{
    /// <summary>
    /// Event Detail Object
    /// </summary>
    public sealed class Event : IComparable
    {
        /// <summary>
        /// Name of the Event
        /// </summary>
        private string name;

        /// <summary>
        /// Name of the Event
        /// </summary>
        public string Name
        {
            get { return name; }
            set { name = value; }
        }
        /// <summary>
        /// Event Message
        /// </summary>
        private string message;

        /// <summary>
        /// Event Message
        /// </summary>
        public string Message
        {
            get { return message; }
            set { message = value; }
        }
        /// <summary>
        /// System Exception (if one)
        /// </summary>
        private System.Exception exception;

        /// <summary>
        /// Event Exception (if one)
        /// </summary>
        public System.Exception Exception
        {
            get { return exception; }
            set { exception = value; }
        }

        /// <summary>
        /// Default Event Constructor
        /// </summary>
        /// <param name="Type">Type of Event</param>
        /// <param name="Name">Name of Event</param>
        /// <param name="Message">Event Message</param>
        /// <param name="Date">Event Date</param>
        /// <returns>Event Class</returns>
        public Event(EventType Type, string Name, string Message, DateTime Date)
        {
            this.eventType = Type;
            this.name = Name;
            this.message = Message;
            this.exception = null;
            this.date = Date;
        }

        /// <summary>
        /// Expanded Event Constructor With Exceptions
        /// </summary>
        /// <param name="Type">Type of Event</param>
        /// <param name="Name">Event Name</param>
        /// <param name="Message">Event Message</param>
        /// <param name="Exception">System.Exception Thrown</param>
        /// <param name="Date">Date of the Event</param>
        /// <returns>Even Class with Exception</returns>
        public Event(EventType Type, string Name, string Message, System.Exception Exception, DateTime Date)
        {
            this.eventType = Type;
            this.name = Name;
            this.message = Message;
            this.exception = Exception;
            this.date = Date;
        }

        /// <summary>
        /// Event Type
        /// </summary>
        private EventType eventType;
        /// <summary>
        /// Event Type
        /// </summary>
        public EventType EventType
        {
            get { return eventType; }
            set { eventType = value; }
        }

        /// <summary>
        /// Date of the Event
        /// </summary>
        private DateTime date;

        /// <summary>
        /// Date of the Event
        /// </summary>
        public DateTime Date
        {
            get { return date; }
            set { date = value; }
        }


        #region IComparable Members

        public int CompareTo(object obj)
        {
            return this.Date.CompareTo(((Event)obj).Date);
        }

        #endregion
    }
}
